/**
  ******************************************************************************
  * @file    stmnvic.c
  * @author  TONLY
  * @version V1.0
  * @date    2022-01-01
  * @brief   嵌套向量中断控制器
  ******************************************************************************
  * @attention
  * 
  *	本程序只供学习使用，未经作者许可，不得用于其它任何用途
  *	版权所有，盗版必究
  *
  * <h2><center>&copy; COPYRIGHT 2022 华清-TONLY </center></h2>
  ******************************************************************************
  */  

/* Includes ------------------------------------------------------------------*/
#include "stmnvic.h"

/* Private define ------------------------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/

/**
  * @brief	嵌套向量中断初始化
  * @param 	None
  *	@retval None
  */
void STMNVIC_Init(void)
{
	static u8 isNVICInit = 0;
	
	if(isNVICInit)
		return;
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);	//设置分组
	isNVICInit = 1;
}


/**
  * @brief  中断配置
  * @param  IRQChannel 			： 中断通道	
  * @param  PreemptionPriority 	： 抢占优先级	
  * @param  SubPriority 		： 从优先级		
  * @retval None
  */
void STMNVIC_Config(u8 IRQChannel,u8 PreemptionPriority,u8 SubPriority)
{
	NVIC_InitTypeDef NVIC_InitStruct;
	
	NVIC_InitStruct.NVIC_IRQChannel	= IRQChannel;
	NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = PreemptionPriority;
	NVIC_InitStruct.NVIC_IRQChannelSubPriority = SubPriority;
	NVIC_Init(&NVIC_InitStruct);
}


/******************* (C) COPYRIGHT 2022 华清-TONLY *************END OF FILE****/
